<!DOCTYPE html><html lang="zh-Hans"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><meta name="description" content="shell截图命令：screencapture"><meta name="keywords" content="iOS"><meta name="author" content="kyren"><meta name="copyright" content="kyren"><title>shell截图命令：screencapture | Kyren's Blog</title><link rel="shortcut icon" href="/melody-favicon.ico"><link rel="stylesheet" href="/css/index.css?version=1.9.0"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@latest/css/font-awesome.min.css?version=1.9.0"><meta name="format-detection" content="telephone=no"><meta http-equiv="x-dns-prefetch-control" content="on"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="dns-prefetch" href="https://hm.baidu.com"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cf87fcdbd9ab7cf93d894f7c219ae78f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();</script><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><script src="https://v1.hitokoto.cn/?encode=js&amp;charset=utf-8&amp;select=.footer_custom_text" defer></script><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容:${query}"}},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  hexoVersion: '6.2.0'
} </script><meta name="generator" content="Hexo 6.2.0"></head><body><i class="fa fa-arrow-right" id="toggle-sidebar" aria-hidden="true"></i><div id="sidebar" data-display="true"><div class="toggle-sidebar-info text-center"><span data-toggle="切换文章详情">切换站点概览</span><hr></div><div class="sidebar-toc"><div class="sidebar-toc__title">目录</div><div class="sidebar-toc__progress"><span class="progress-notice">你已经读了</span><span class="progress-num">0</span><span class="progress-percentage">%</span><div class="sidebar-toc__progress-bar"></div></div><div class="sidebar-toc__content"></div></div><div class="author-info hide"><div class="author-info__avatar text-center"><img src="https://avatars.githubusercontent.com/u/5827823?v=4"></div><div class="author-info__name text-center">kyren</div><div class="author-info__description text-center">huluo的技术博客</div><div class="follow-button"><a target="_blank" rel="noopener" href="https://github.com/huluo666">Follow Me</a></div><hr><div class="author-info-articles"><a class="author-info-articles__archives article-meta" href="/archives"><span class="pull-left">文章</span><span class="pull-right">239</span></a><a class="author-info-articles__tags article-meta" href="/tags"><span class="pull-left">标签</span><span class="pull-right">41</span></a><a class="author-info-articles__categories article-meta" href="/categories"><span class="pull-left">分类</span><span class="pull-right">29</span></a></div><hr><div class="author-info-links"><div class="author-info-links__title text-center">Links</div><a class="author-info-links__name text-center" target="_blank" rel="noopener" href="http://192.168.2.212:9090/">Jira</a><a class="author-info-links__name text-center" target="_blank" rel="noopener" href="http://192.168.2.212:8090/">Confluence</a><a class="author-info-links__name text-center" target="_blank" rel="noopener" href="http://bloc.leniugame.com/">Leniu</a></div></div></div><div id="content-outer"><div class="no-bg" id="top-container"><div id="page-header"><span class="pull-left"> <a id="site-name" href="/">Kyren's Blog</a></span><i class="fa fa-bars toggle-menu pull-right" aria-hidden="true"></i><span class="pull-right menus">   <a class="site-page" href="/">主页</a><a class="site-page" href="/essay">随笔</a><a class="site-page" href="/archives">归档</a><a class="site-page" href="/tags">标签</a><a class="site-page" href="/categories">分类</a><a class="site-page" href="/about">关于</a></span><span class="pull-right"><a class="site-page social-icon search"><i class="fa fa-search"></i><span> 搜索</span></a></span></div><div id="post-info"><div id="post-title">shell截图命令：screencapture</div><div id="post-meta"><time class="post-meta__date"><i class="fa fa-calendar" aria-hidden="true"></i> 2017-02-04</time></div></div></div><div class="layout" id="content-inner"><article id="post"><div class="article-container" id="post-content"><p>使用方法：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">screencapture -i test.png</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>执行后会调用系统默认的截图程序，也就是按<code>cmd-shift-4</code>出来的那个截图程序。截图完毕后，会保存到test.png中。</p>
<p><code>-i</code>模式默认是自由模式，按一下空格键，可以在自由模式和窗口模式间切换。按下control键，截图就不会保存到文件中，而是保存到剪贴板中。</p>
<p>screencapture命令的其他选项：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">-c         强制截图保存到剪贴板而不是文件中</span><br><span class="line">-C         截图时保留光标（只在非交互模式下有效）</span><br><span class="line">-d         display errors to the user graphically（不知道啥意思）</span><br><span class="line">-i         交互模式截取屏幕。可以是选区或者是窗口。</span><br><span class="line">             control key - 截图保存到剪贴板</span><br><span class="line">             space key   - 在鼠标选区模式和窗口模式间切换</span><br><span class="line">             escape key  - 退出截图</span><br><span class="line">-m         只截取主显示器（-i模式下无效）</span><br><span class="line">-M         截图完毕后，会打开邮件客户端，图片就躺在邮件正文中</span><br><span class="line">-o         在窗口模式下，不截取窗口的阴影</span><br><span class="line">-P         截图完毕后，在图片预览中打开</span><br><span class="line">-s         只允许鼠标选择模式</span><br><span class="line">-S         窗口模式下，截取屏幕而不是窗口</span><br><span class="line">-t&lt;format&gt; 指定图片格式，模式是png。可选的有pdf, jpg, tiff等</span><br><span class="line">-T&lt;seconds&gt; 延时截取，默认为5秒。</span><br><span class="line">-w         只允许窗口截取模式</span><br><span class="line">-W         开始交互截取模式，默认为窗口模式（只是默认模式与-i不同）</span><br><span class="line">-x         不播放声效</span><br><span class="line">-a         do not include windows attached to selected windows（不懂）</span><br><span class="line">-r         不向图片中加入dpi信息</span><br><span class="line">-l&lt;windowid&gt; 抓取指定windowid的窗口截图</span><br><span class="line">-R&lt;x,y,w,h&gt; 抓取指定区域的截图</span><br><span class="line">-B&lt;bundleid&gt; 截图输出会被bundleid指出的程序打开</span><br></pre></td></tr></table></figure>





<p>cmd+shift+3：捕获整个屏幕</p>
<p>cmd+shift+4：捕获选择的区域</p>
<p>cmd+shift+4  再按space：捕获某个应用程序的窗口</p>
<p>如果在使用标准的截图快捷键的同时按下Control键，则不需要在桌面上生成文件，而是直接让图片进入剪贴板。</p>
<p>保存截图到桌面</p>
<p>按<code>Command＋shift＋4</code> 后 ,画一个抓取的区域，不要松开鼠标，接着</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">1. 按住空格可以移动这个区域</span><br><span class="line">2. 按住 Shift后，将锁定X 或者 Y轴进行拖动</span><br><span class="line">3. 按住 Option后 将按照区域圆心进行放大.</span><br></pre></td></tr></table></figure>

<p>最后所有截图将直接显示在桌面上。</p>
<p>截图也可以在屏保的使用，操作如下</p>
<p>首先，进入“<code>系统偏好设置” -&gt; “桌面于屏幕保护” -&gt; “屏幕保护程序</code>”。选择你想截屏的屏幕保护，按住Command-Shift，然后点击“测试”按钮。</p>
<p>等屏幕保护开始运行后，不要松开<code>Command-Shift</code>键，再按照自己需求按3&#x2F;4键。一张屏幕保护的截屏就完成了。</p>
<p>这个可以应用到很多地方，发挥你的扩展思维吧~</p>
<p>默认截图文件名是中文的，如何截图文件名改成英文命名，文件名由两部分构成：前缀和时间戳。</p>
<p>首先来修改前缀。打开终端（可以在Spotlight中输入“Terminal”并点选“应用程序”右边的“终端”），输入以下命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">defaults write com.apple.screencapture name Screenshot</span><br><span class="line">killall SystemUIServer</span><br></pre></td></tr></table></figure>

<p>将蓝色部分替换为任意所需的单词即可，例如“<code>Screenshot</code>”。要让前缀修改生效，需要重新启动系统。</p>
<p>如何弄掉阴影</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">defaults write com.apple.screencapture disable-shadow -bool true</span><br><span class="line">killall SystemUIServer</span><br></pre></td></tr></table></figure>

<p>恢复</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">defaults write com.apple.screencapture disable-shadow -bool false</span><br><span class="line">killall SystemUIServer</span><br></pre></td></tr></table></figure></div></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">kyren</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://huluo666.gitee.io/2017/02/04/shell截图命令：screencapture/">http://huluo666.gitee.io/2017/02/04/shell截图命令：screencapture/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://huluo666.gitee.io">Kyren's Blog</a>！</span></div></div><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/iOS/">iOS</a></div><nav id="pagination"><div class="prev-post pull-left"><a href="/2017/02/07/%E6%9E%81%E5%AE%A2%E5%AF%BC%E8%88%AA/"><i class="fa fa-chevron-left">  </i><span>极客导航</span></a></div><div class="next-post pull-right"><a href="/2017/02/03/Mac%20Nginx%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA/"><span>Mac Nginx服务器搭建</span><i class="fa fa-chevron-right"></i></a></div></nav></div></div><footer><div class="layout" id="footer"><div class="copyright">&copy;2022 By kyren</div><div class="framework-info"><span>驱动 - </span><a target="_blank" rel="noopener" href="http://hexo.io"><span>Hexo</span></a><span class="footer-separator">|</span><span>主题 - </span><a target="_blank" rel="noopener" href="https://github.com/Molunerfinn/hexo-theme-melody"><span>Melody</span></a></div><div class="footer_custom_text">hitokoto</div><div class="busuanzi"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><span id="busuanzi_container_page_pv"><i class="fa fa-file"></i><span id="busuanzi_value_page_pv"></span><span></span></span></div></div></footer><i class="fa fa-arrow-up" id="go-up" aria-hidden="true"></i><script src="https://cdn.jsdelivr.net/npm/animejs@latest/lib/anime.min.js"></script><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@latest/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-ui-pack@latest/velocity.ui.min.js"></script><script src="/js/utils.js?version=1.9.0"></script><script src="/js/fancybox.js?version=1.9.0"></script><script src="/js/sidebar.js?version=1.9.0"></script><script src="/js/copy.js?version=1.9.0"></script><script src="/js/fireworks.js?version=1.9.0"></script><script src="/js/transition.js?version=1.9.0"></script><script src="/js/scroll.js?version=1.9.0"></script><script src="/js/head.js?version=1.9.0"></script><script src="/js/search/local-search.js"></script><script>if(/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
  $('#nav').addClass('is-mobile')
  $('footer').addClass('is-mobile')
  $('#top-container').addClass('is-mobile')
}</script><div class="search-dialog" id="local-search"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章"></div></div></div><hr><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fa fa-times"></i></span></div><div class="search-mask"></div></body></html>